import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";

import Layout from "@/layout/index.vue";
// 多级菜单
import nestedRouter from "./modules/nested.ts";
// 常用功能
import commonFeature from "./modules/common-feature.ts";
/**
 * 静态路由
 */
export const constantRoutes: RouteRecordRaw[] = [
  {
    path: "/",
    name: "/",
    component: Layout,
    redirect: "/dashboard",
    children: [
      {
        path: "dashboard",
        name: "Dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        meta: {
          title: "首页",
          icon: "dashboard",
          affix: true,
        },
      },
    ],
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      hidden: true,
    },
  },
  // {
  //   path: "/auth",
  //   component: Layout,
  //   redirect: "/auth/role",
  //   name: "auth",
  //   meta: { title: "系统管理", icon: "system" },
  //   children: [
  //     {
  //       path: "user",
  //       name: "authUser",
  //       component: () => import("@/views/auth/user/index.vue"),
  //       meta: { title: "账号管理", icon: "user" },
  //     },
  //     {
  //       path: "role",
  //       name: "authRole",
  //       component: () => import("@/views/auth/role/index.vue"),
  //       meta: { title: "角色管理", icon: "role" },
  //     },
  //     {
  //       path: "permission",
  //       name: "authPermission",
  //       component: () => import("@/views/auth/permission/index.vue"),
  //       meta: { title: "资源管理", icon: "menu" },
  //     },
  //   ],
  // },

  // 嵌套路由
  nestedRouter,
  commonFeature,
  {
    path: "/401",
    component: () => import("@/views/error-page/401.vue"),
    meta: { hidden: true },
  },
  {
    path: "/404",
    component: () => import("@/views/error-page/404.vue"),
    meta: { hidden: true },
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes: constantRoutes,
});

export default router;
